Repository navigation
cmake: Replace PYTHON_EXECUTABLE alias with Python3_EXECUTABLE - #8285
Merged
Merged
Conversation
Use the variables of find_package(Python3) directly and drop the FindPythonInterp-style aliases PYTHON_EXECUTABLE and PYTHON_SITEARCH. Addon builds run against an installed GRASS and never include CheckDependentLibraries, so build_addon now calls find_package(Python3) itself. g.extension passes its interpreter as Python3_EXECUTABLE, which FindPython3 uses as the interpreter to find.
echoix
force-pushed
the
claude/jolly-thompson-lsvcu3
branch
from
November 28, 2026 18:45
5722fdd to
300e5ca
Compare
nilason
approved these changes
Nov 29, 2026
petrasovaa
added a commit
to petrasovaa/grass
that referenced
this pull request
Dec 2, 2026
Since the rename in OSGeo#8285, the custom command passes the interpreter to ctypesgen.cmake as PYTHON_EXECUTABLE while the script reads Python3_EXECUTABLE, so the script ran run.py on its own. That works on Linux and macOS, where run.py is executable and has a shebang, but on Windows every grass.lib module fails with "inappropriate file type or format". Pass the variable under the name the script uses. The error message was also empty when ctypesgen produced no output, which is what happens when it cannot start, so include the exit code.
petrasovaa
added a commit
to petrasovaa/grass
that referenced
this pull request
Dec 2, 2026
Since the rename in OSGeo#8285, the custom command passes the interpreter to ctypesgen.cmake as PYTHON_EXECUTABLE while the script reads Python3_EXECUTABLE, so the script ran run.py on its own. That works on Linux and macOS, where run.py is executable and has a shebang, but on Windows every grass.lib module fails with "inappropriate file type or format". Pass the variable under the name the script uses. The error message was also empty when ctypesgen produced no output, which is what happens when it cannot start, so include the exit code.
petrasovaa
added a commit
to petrasovaa/grass
that referenced
this pull request
Dec 2, 2026
Since the rename in OSGeo#8285, the custom command passes the interpreter to ctypesgen.cmake as PYTHON_EXECUTABLE while the script reads Python3_EXECUTABLE, so the script ran run.py on its own. That works on Linux and macOS, where run.py is executable and has a shebang, but on Windows every grass.lib module fails with "inappropriate file type or format". Pass the variable under the name the script uses. The error message was also empty when ctypesgen produced no output, which is what happens when it cannot start, so include the exit code.
petrasovaa
added a commit
to petrasovaa/grass
that referenced
this pull request
Dec 2, 2026
Since the rename in OSGeo#8285, the custom command passes the interpreter to ctypesgen.cmake as PYTHON_EXECUTABLE while the script reads Python3_EXECUTABLE, so the script ran run.py on its own. That works on Linux and macOS, where run.py is executable and has a shebang, but on Windows every grass.lib module fails with "inappropriate file type or format". Pass the variable under the name the script uses. The error message was also empty when ctypesgen produced no output, which is what happens when it cannot start, so include the exit code.
petrasovaa
added a commit
to petrasovaa/grass
that referenced
this pull request
Dec 2, 2026
Since the rename in OSGeo#8285, the custom command passes the interpreter to ctypesgen.cmake as PYTHON_EXECUTABLE while the script reads Python3_EXECUTABLE, so the script ran run.py on its own. That works on Linux and macOS, where run.py is executable and has a shebang, but on Windows every grass.lib module fails with "inappropriate file type or format". Pass the variable under the name the script uses. The error message was also empty when ctypesgen produced no output, which is what happens when it cannot start, so include the exit code.
petrasovaa
added a commit
that referenced
this pull request
Dec 3, 2026
Since #8285, the custom command passes the interpreter to ctypesgen.cmake as PYTHON_EXECUTABLE while the script reads Python3_EXECUTABLE, so the script ran run.py on its own. That works where run.py is executable with a shebang, but on Windows every grass.lib module fails. Pass the variable under the name the script uses, require it in the script so that a mismatch fails at once, and include the command and exit code in the error message, which was empty in this case. Drafted with Claude Code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the
PYTHON_EXECUTABLEandPYTHON_SITEARCHaliases, copied fromPython3_*inCheckDependentLibraries.cmake, with thePython3_EXECUTABLEandPython3_SITEARCHvariables fromfind_package(Python3). Also removes the commented-outPythonLibs/Numpyblock.Addon builds run against an installed GRASS and never include
CheckDependentLibraries.cmake, sobuild_addon.cmakenow callsfind_package(Python3 REQUIRED COMPONENTS Interpreter)itself.g.extensionnow passes-DPython3_EXECUTABLE=<sys.executable>, which FindPython3 uses as the interpreter to find. The ctypesgen sub-script keeps its ownPYTHON_EXECUTABLEinput name.I used
${Python3_EXECUTABLE}everywhere rather thanPython3::Interpreter, since almost all uses follow${grass_env_command}and are not the first word of theCOMMAND.Tested with a CMake build (GUI off, since wxPython is not installed) and
cmake --install:grass.libimports.g.extensionbuilt and installed addons from grass-addons against the installed tree:r.accumulate(C, OpenMP, images),d.frameandr3.to.group(script and compiled), and ther.demwrapper with its ten sub-addons. All produced the HTML, man and Markdown docs, and the installed tools run with--help.g.extension, shows the newfind_packageis needed, for script and C addons alike. Without it the variable is empty and the docs commands only run through the script shebang. With it they use the found interpreter.compileallcommands use the found interpreter. The GUI build itself was not run.pre-commitpasses.None of the grass-addons
CMakeLists.txtfiles referencePYTHON_EXECUTABLE. The only build error isman/GUI_WXPYTHONmissing when the GUI is off, which is unrelated and already noted by a TODO inman/CMakeLists.txt.AI assistance was used to make and review the change.
Suggested squash commit message